package com.hyzx.qbasic.admin.domain.repository.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hyzx.qbasic.admin.model.po.ProcessConfigPO;
import com.hyzx.qbasic.admin.model.po.ProcessConfigPagedInfoPO;
import com.hyzx.qbasic.admin.domain.dao.ProcessConfigMapper;
import com.hyzx.qbasic.admin.domain.repository.IProcessConfigRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by 黄江华 on 2018/11/28
 */

@Repository
public class ProcessConfigRepositoryImpl implements IProcessConfigRepository {

    @Autowired
    private ProcessConfigMapper configMapper;

    @Override
    public PageInfo<ProcessConfigPagedInfoPO> getPagedProcessConfigList(int pageNum, int pageSize, Integer processCategoryId, String processDefinitionName) {
        PageInfo pageInfo = PageHelper.startPage(pageNum, pageSize)
                .doSelectPageInfo(() -> configMapper.getPagedProcessConfigList(processCategoryId, processDefinitionName));

        return pageInfo;
    }

    @Override
    public boolean addProcessConfig(ProcessConfigPO record) {
        return configMapper.addProcessConfig(record) > 0;
    }

    @Override
    public boolean deleteProcessConfig(List<Integer> processConfigIdList) {
        return configMapper.deleteProcessConfig(processConfigIdList) > 0;
    }

    @Override
    public boolean deleteProcessConfigByKey(List<String> processConfigKeyList) {
        return configMapper.deleteProcessConfigByKey(processConfigKeyList)>0;
    }

    @Override
    public ProcessConfigPO getProcessConfigById(int processConfigId) {
        return configMapper.getProcessConfigById(processConfigId);
    }

    @Override
    public ProcessConfigPO getProcessConfigByKey(String processConfigKey) {
        return configMapper.getProcessConfigByKey(processConfigKey);
    }

    @Override
    public boolean editProcessConfig(ProcessConfigPO record) {
        return configMapper.editProcessConfig(record) > 0;
    }
}
